<include file="Public/head" />
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.css" />
<script src="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.js" type="text/javascript"></script>
<style>
    .select_model{
        -moz-appearance: none;background: rgba(0, 0, 0, 0) url("{:get_style_cdnurl()}paimai/yunying/images/sanjiao.jpg") no-repeat scroll 115px 5px;
        border: 1px solid #d7d7d7;float: left;height: 26px;line-height: 26px;margin-right: 8px;text-indent: 2px;width: 136px;}
    .table .mcenter{vertical-align: middle;text-align: center;}
    .repair_check_total {text-align: left;  font-size:16px; display: block; height: 25px; line-height: 25px; margin-top: 10px; width: 100%;  }
    .yuyue ul li{width: 150px;}
</style>
</head>
<include file="Public/common_header" />
<div class="mian">
    <include file="Public/sidebar" menu="cxtj.wbjlcxgl"/>
    <div class="mianR">
        <div class="yuyue">
            <ul>
                <li onclick="change_search(1);get_list(1);" class="yuCurrent">车商维保查询记录</li>
                <li onclick="change_search(2);get_list(2);">第三方接口查询记录</li>
            </ul>
        </div>
        <div class="yuList">
            <div class="repair_check_total">
                <!--<b>昨日查询：</b><b style="color:#ff5d5d">100</b>次，-->
                <!--<b>成功生成：</b><b style="color:#ff5d5d">88</b>次；-->
            </div>
            <div class="yuSuo clearfix">
                <form id="searchFrom">
                    <input id="status" name="status" type="hidden" value="{$params.status|default=1}"/>
                    <input type="text" id="vin" name="vin" placeholder="查询VIN码" value="" class="suoDian" style="margin-right: 10px;"/>

                    <div id="search4" style="display: none;">
                        <select name="check_platform" id="check_platform" class="select_model">
                            <option value="0">选择查询平台</option>
                            <?php foreach(C('DEALER_REPAIR_CHECK_PLATFORM') as $key=>$val):?>
                            <option value="{$key}">{$val}</option>
                            <?php endforeach ?>
                        </select>
                    </div>

                    <input id="start_time" name="start_time" value="" readonly placeholder="查询开始时间" type="text">
                    <em></em>
                    <input id="end_time"  name="end_time" value="" readonly placeholder="查询结束时间" style="margin-right: 10px;" type="text">

                    <div id="search3">
                        <select name="data_from" id="data_from" class="select_model">
                            <option value="0">选择数据来源</option>
                            <?php foreach(C('DEALER_REPAIR_COME_FROM') as $key=>$val):?>
                            <option value="{$key}">{$val}</option>
                            <?php endforeach ?>
                        </select>
                    </div>

                    <select name="order_status" id="order_status" class="select_model">
                        <option value="0">选择订单状态</option>
                        <?php foreach(C('DEALER_REPAIR_CHECK_SEARCH_STATUS') as $key=>$val):?>
                        <option value="{$key}">{$val}</option>
                        <?php endforeach ?>
                    </select>

                    <div id="search1">
                        <input type="text" id="dealer_info" name="dealer_info" placeholder="查询车商ID/账号/联系人/联系方式" value="" class="suoDian" style="width: 220px;"/>
                    </div>

                    <div id="search2" style="display: none;">
                        <select name="third_channel" id="third_channel" class="select_model">
                            <option value="0">选择第三方渠道</option>
                            <?php foreach(C('DEALER_REPAIR_CHECK_THIRD_PARTY') as $key=>$val):?>
                            <option value="{$key}">{$val}</option>
                            <?php endforeach ?>
                        </select>
                    </div>
                </form>
                <input type="button"  id="search" onclick="search()" value="搜索" class="suoSou">
            </div>

            <div class="listBox" id="listBox">

            </div>
        </div>
        <div class="clear"></div>
    </div>
</div>
</body>
<script type="text/javascript">

    get_list(1);
    function get_list(t) {
        clear_form_params();
        $("#status").val(t);
        get_repair_check_count(t);
        $.get("/RepairCheck/repair_check_list", {status:t}, function (data) {
            $("#listBox").html(data);
        }, "html");
    }

    function get_page(p) {
        var data = $("#searchFrom").serialize() + "&" + encodeURI("p=" + p);
        $.get("/RepairCheck/repair_check_list", data, function (data) {
            $("#listBox").html(data);
        }, "html");
    }

    function search() {
        var t = $("#status").val();
        get_repair_check_count(t);
        $.get("/RepairCheck/repair_check_list", $("#searchFrom").serialize(), function (data) {
            $("#listBox").html(data);
        }, "html");
    }

    function change_search(st) {
        var s1 = $("#search1"),s2 = $("#search2"),s3 = $("#search3"),s4 = $("#search4");
        if (st == 1) {
            s1.show();
            s3.show();
            s2.hide();
            s4.hide();
        }else{
            s2.show();
            s4.show();
            s1.hide();
            s3.hide();
        }
    }
    /**
     * repair check count
     * @param t
     */
    function get_repair_check_count(t){
        var vin = $("#vin").val();
        var check_platform = $('#check_platform').val();
        var start_time = $("#start_time").val();
        var end_time = $('#end_time').val();
        var data_from = $("#data_from").val();
        var order_status = $('#order_status').val();
        var dealer_info = $('#dealer_info').val();
        var third_channel = $('#third_channel').val();
        var post_data = {
            'status': t,
            'vin': vin,
            'check_platform':check_platform,
            'start_time' : start_time,
            'end_time':end_time,
            'data_from':data_from,
            'order_status':order_status,
            'dealer_info':dealer_info,
            'third_channel':third_channel
        }
        $.post("/RepairCheck/repair_check_count", post_data, function (data) {
            var type = data.data.type;
            var str = '';
            if(type == 1){  //only start time
                str = "<b>" + start_time+"至 至今 查询：</b><b style='color:#ff5d5d'>" +data.data.total+"</b>次，" + "<b>成功生成：</b><b style='color:#ff5d5d'>"+data.data.success_num+"</b>次；";
            }else if(type == 2){ //only end time
                str = "<b>" + end_time + "之前 查询：</b><b style='color:#ff5d5d'>"+data.data.total+"</b>次，" + "<b>成功生成：</b><b style='color:#ff5d5d'>"+data.data.success_num+"</b>次；";
            }else if(type == 3){ //both start time and end time
                str = "<b>" + start_time+" 至 " + end_time + " 查询：</b><b style='color:#ff5d5d'>"+data.data.total+"</b>次，" + "<b>成功生成：</b><b style='color:#ff5d5d'>"+data.data.success_num+"</b>次；";
            }else{ //default
                str = "<b>昨日查询：</b><b style='color:#ff5d5d'>"+data.data.total+"</b>次， " + "<b>成功生成：</b><b style='color:#ff5d5d'>"+data.data.success_num+"</b>次；";
            }
            $(".repair_check_total").html(str);
        }, "JSON");
    }

    function clear_form_params(){
        $(':input').not(':button, :submit, :reset, :hidden, select').val('');
        if($("#order_status option").length > 1){
            $("#order_status").val(0);
        }
        if($("#check_platform option").length > 1){
            $("#check_platform").val(0);
        }
        if($("#data_from option").length > 1){
            $("#data_from").val(0);
        }
        if($("#third_channel option").length > 1){
            $("#third_channel").val(0);
        }
    }

    $("#start_time").ymdateplugin({
        changeMonth: true,
        changeYear: true
    });
    $("#end_time").ymdateplugin({
        changeMonth: true,
        changeYear: true
    });
</script>
</html>